#pragma once

#include "Continuation.h"


namespace uml {

const bool Continuation::setting_default_ = true;
Continuation::Continuation(const QString& umlType)
    : NamedElement(umlType) {}

void Continuation::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    NamedElement::fromJson(json, errorList);
    InteractionFragment::fromJson(json, errorList);
    setting_ = json.value("setting").toBool(setting_default_);
}

void Continuation::toJson(QJsonObject& json) {
    NamedElement::toJson(json);
    InteractionFragment::toJson(json);
    if (setting_ != setting_default_) {
        json.insert("setting", setting_);
    }
}

/// <summary>
/// setting getter
/// True: when the Continuation is at the end of the enclosing InteractionFragment
/// and False when it is in the beginning.
/// </summary>
bool Continuation::setting() const {
    return setting_;
}

/// <summary>
/// setting setter
/// True: when the Continuation is at the end of the enclosing InteractionFragment
/// and False when it is in the beginning.
/// </summary>
void Continuation::setSetting(bool value) {
    setting_ = value;
}

} // namespace uml
